# -*- coding: utf-8 -*-
"""
Created on Mon Jun 14 23:15:58 2021

@author: bwh
"""
from random import random
from random import seed
from time import perf_counter
trytimes=100*100*100*100
hits=0
start=perf_counter()
seed()
for i in range(1,trytimes+1):
    x,y=random(),random()
    distance=x**2+y**2
    if distance<=1:
        hits=hits+1
pi=4*hits/trytimes
print("圆周率计算值是:{:.16f}".format(pi))
end=perf_counter()
timelong=end-start
print("用时为:{:.8f}秒".format(timelong))